package com.ja.openchat.views;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;


public class NoScrollVerticalViewPager extends VerticalViewPager {
    private boolean cannotSlide = false;//  true:不能滑动

    public NoScrollVerticalViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public NoScrollVerticalViewPager(Context context) {
        super(context);
    }

    public void setNoScroll(boolean cannotSlide) {
        this.cannotSlide = cannotSlide;
    }


    @Override
    public boolean onTouchEvent(MotionEvent event) {
        try {
            return !cannotSlide && super.onTouchEvent(event);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return super.onTouchEvent(event);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent event) {
        try {
            return !cannotSlide && super.onInterceptTouchEvent(event);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }
}
